@extends('admin.base')
@section('title', '提现列表')
@section('content')
    <div class="layui-card">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box">
                <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
                <span class="layui-btn-sm" href="{{url('admin/deposit/index')}}">提现列表</span>
            </div>
        </fieldset>
        <div class="layui-card-header">
            <div>
                <span class="pull-left">
                  <div class="layui-form">
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label">关键字</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="sub_keywords" name="keywords"
                                   value="{{ isset($request->keywords) ? $request->keywords : '' }}"
                                   placeholder="请输入账户">
                        </div>
                      </div>
                        <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <select name="sh_state" lay-verify="required">
                                <option value="0">请选择</option>
                                <option value="3" @if($request->state == 3) selected @endif>待审核</option>
                                <option value="2" @if($request->state == 2) selected @endif>已通过</option>
                                <option value="1" @if($request->state == 1) selected @endif>已驳回</option>
                            </select>
                        </div>
                      </div>
                        <div class="layui-inline">
                        <label class="layui-form-label" style="width:120px">提现方式</label>
                        <div class="layui-input-inline">
                            <select name="sub_type" lay-verify="required">
                                <option value="0">请选择</option>
                                <option value="1" @if($request->sub_type == 1) selected @endif>银行卡</option>
                                <option value="2" @if($request->sub_type == 2) selected @endif>微信</option>
                                <option value="3" @if($request->sub_type == 3) selected @endif>支付宝</option>
                            </select>
                        </div>
                        </div>
                    </div>
                  </div>
                </span>
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit lay-filter="selectsub" style="margin-top:-10px">搜索</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <style>
                table tr td.tc, table tr th.tc {
                    text-align: center;
                    cursor: default;
                }
            </style>
            <table class="layui-table" lay-even lay-size="">
                <colgroup>
                    <col width="">
                    <col width="">
                    <col width="">
                    <col width="">
                </colgroup>
                <thead>
                <tr>
                    <th class="tc">ID</th>
                    <th class="tc">账户</th>
                    <th class="tc">提现金额</th>
                    <th class="tc">提现前金额</th>
                    <th class="tc">提现后金额</th>
                    <th class="tc">真实姓名</th>
                    <th class="tc">账号/银行卡号</th>
                    <th class="tc">开户银行/提现类型</th>
                    <th class="tc">开户支行</th>
                    <th class="tc">提现方式</th>
                    <th class="tc">审核状态</th>
                    <th class="tc">驳回原因</th>
                    <th class="tc">提现时间</th>
                    <th class="tc">操作</th>
                </tr>
                <tbody>
                @if($list->isEmpty())
                    <tr>
                        <td colspan="14 class="tc">暂无数据</td>
                    </tr>
                @else
                    @foreach ($list as $v)
                        <tr>
                            <td class="tc">{{$v->id}}</td>
                            <td class="tc">{{ $v->username }}</td>
                            <td class="tc">{{ $v->num }}</td>
                            <td class="tc">{{ $v->num_befor }}</td>
                            <td class="tc">{{ $v->num_after }}</td>
                            <td class="tc">{{ $v->name }}</td>
                            <td class="tc">{{ $v->account }}</td>
                            <td class="tc">{{ $v->bank }}</td>
                            <td class="tc">{{ $v->bank_name }}</td>
                            <td class="tc">
                                @if($v->type == 1)银行卡
                                @elseif($v->type == 2)微信
                                @elseif($v->type == 3)支付宝
                                @endif
                            </td>
                            <td class="tc">
                                @if($v->state == 1)已提现
                                @elseif($v->state == 2)驳回
                                @elseif($v->state == 3)待审核
                                @endif
                            </td>
                            <td class="tc">{{ $v->remark }}</td>
                            <td class="tc">{{ $v->created_at }}</td>
                            <td class="tc">
                                <div class="layui-btn-group">
                                    @if($v->state == 1)
                                        <button class="layui-btn layui-btn-sm layui-btn-disabled">无
                                        </button>
                                    @elseif($v->state == 2)
                                        <button class="layui-btn layui-btn-sm layui-btn-disabled">无
                                        </button>
                                    @elseif($v->state == 3)
                                        <button class="layui-btn layui-btn-sm"
                                                onclick="active('{{url('admin/deposit/auth_ok_check')}}','{{$v->id}}','请输入操作密码');">通过
                                        </button>
                                        <button class="layui-btn layui-btn-sm layui-btn-danger"
                                                onclick="active('{{url('admin/deposit/auth_no_remark')}}','{{$v->id}}');">
                                            驳回
                                        </button>
                                    @endif

                                </div>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                </thead>
            </table>
            <!-- 分页 -->
            <div class="sabrosus">{{ $list->appends(['type'=>$request->type,'keywords'=>$request->keywords,'state'=>$request->state])->links() }}</div>
        <!-- {{$list->total()}} -->
        </div>

    </div>
@endsection
@section('js')
    <script>
        layui.use('form', function () {
            var form = layui.form;

            //搜索
            form.on('submit(selectsub)', function (data) {
                let keywords = $('#sub_keywords').val();//关键字
                let sh_state = $("select[name=sh_state]").val();
                var sub_type = $("select[name=sub_type]").val();
                location.href = "{{url('admin/deposit/index')}}" + "?keywords=" + keywords + "&state=" + sh_state+'&sub_type='+sub_type;
                return false;
            });
        });

        function auth_ok(url, id, state) {
            layer.confirm('确认通过？', {
                btn: ['确定', '取消']//按钮
            }, function (index) {

                layer.close(index);
                //此处请求后台程序，下方是成功后的前台处理……
                $.ajax({
                    url: url,
                    type: 'post',
                    async: false,
                    data: {'id': id, 'state': state, _token: "{{csrf_token()}}"},
                    success: function (data) {
                        layer.msg(data.msg);
                        location.href = location.href;
                    },
                    error: function () {

                    }
                })
            });
        }
    </script>
@endsection